<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>问答管理</title>
<%@ include file="../../common/importLib.jsp" %>
<script type="text/javascript" src="../common/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="../common/jquery-cascade/js/jquery.cityselect.js"></script>
<!-- <script type="text/javascript" src="js/mrjy.maintain.js"></script>	 -->
<script type="text/javascript">
	/**
	 * 增删改查参数设置
	 */
	tableTitle = "回复表";
	tableURL = getTimeURL("questionComment/selectQuestionCommentListPage.do");
	toolbarView = 2;
	tableColumns = [[{field:'ck',checkbox:true},
	                {field:'id',title:'id',width:0,rowspan:1},
				    {field:'opt',title:'操作',width:130,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){	
							var queryUrl = 'questionComment/queryById.do?id=' + rowData.id;						
							return "<a title='修改' class='xxl_linkbutton' iconCls='icon-edit' href='javascript:datagridUpdate(\"" + queryUrl + "\")'>修改</a>";
						}
					},
					{field:'commentContent',title:'回答内容',width:300,rowspan:1},	
					{field:'userName',title:'回答者',width:100,rowspan:1},
					{field:'questionContent',title:'问题标题',width:300,rowspan:1},
					{field:'commentedName',title:'被回答者',width:150,rowspan:1},	
					{field:'commentTimeString',title:'回答时间',width:150,rowspan:1},
					{field:'commentNum',title:'评论数',width:100,rowspan:1},
					{field:'goodNum',title:'点赞数',width:100,rowspan:1},
					{field:'disableFlag',title:'禁用状态',width:80,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.disableFlag == 0){
								return "<font color='green'>起用</font>";
							}else{
								return "<font color='red'>禁用</font>";
							}
						}
					}]];
	
	var addWidth = 700; //添加窗口宽度
	var addHeight = 350; //添加窗口高度
	var addTitle = "添加回答"; //添加标题
	var updateWidth = 700; //修改窗口宽度
	var updateHeight = 450; //修改窗口高度
	var updateTitle = "修改回答信息"; //修改标题
	var updateDisableFlagUri = "questionComment/updateDisableFlag.do"; //禁用、起用记录
	//var deleteUri = "questionInfo/deleteByIds.do"; //删除记录
	
	/**
	 * 初始化添加表单
	 */	
	function initAddForm(){	
				
	}
	
	/**
	 * 初始化修改表单
	 */
	function initUpdateForm(jsonObject){
		$("#idUpdate").val(jsonObject.questionComment.id);
		$("#commentContentUpdate").val(jsonObject.questionComment.commentContent);
		$("#questionIdUpdate").val(jsonObject.questionComment.questionId);
		$("#userIdUpdate").val(jsonObject.questionComment.userId);
		
	}
	
	function ajaxLoading(){   
	    $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:600}).appendTo("#datagrid_import");   
	    $("<div class=\"datagrid-mask-msg\"></div>").html("正在处理，请稍候。。。").appendTo("#datagrid_import").css({display:"block",left:(850 - 190) / 2,top:(600 - 45) / 2});   
	 }   
	 function ajaxLoadEnd(){   
	     $(".datagrid-mask").remove();   
	     $(".datagrid-mask-msg").remove();               
	} 
	//更新提交的方法
	function updateFormSubmit(){
		var params = getFormJson($('#update_form'));
		$.ajax({
			  type: 'POST',
			  url: '../queries/questionComment/updateById.do',
			  data: params,
			  dataType: 'json',
			  async: false,
			  success: function(data){
				  if(data.err_code ==0){
					  $('#datagrid_update').window('close');
					  $('#datagrid_table').datagrid('reload');
				  }
			  },
			  error: function(xhr, type){
			    alert('Ajax error!')
			  }
		});
	}
	//将form中的值转换为键值对。
	function getFormJson(frm) {
	    var o = {};
	    var a = $(frm).serializeArray();
	    $.each(a, function () {
	        if (o[this.name] !== undefined) {
	            if (!o[this.name].push) {
	                o[this.name] = [o[this.name]];
	            }
	            o[this.name].push(this.value || '');
	        } else {
	            o[this.name] = this.value || '';
	        }
	    });

	    return o;
	}
</script>
<script type="text/javascript">

</script>
</head>
<body id="layout" class="easyui-layout">

	<div style="background: none repeat scroll 0% 0% #EFEFEF; height:75px; padding: 6px 2px; border-bottom: 1px solid #CCC;"
		region="north"  split="false" title="条件查询">
	<form  id="searchForm" >
	<table>
		<tr>
			<td>回答内容：</td><td><input type="text" name="commentContent"/> </td>					
			<td>回答者：</td><td><input type="text" name="userName"/> </td>	
			<td>问题标题：</td><td><input type="text" name="questionContent"/> </td>					
			<td>被回答者：</td><td><input type="text" name="commentedName"/> </td>	
			<td><a class="easyui-linkbutton" id="search" iconCLs="icon-search"  onclick="searchTable()">搜索</a></td>
			<td><a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('searchForm').reset();reload();">清空</a></td>
		</tr>
	
	</table>
	</form>
	</div>
	<div region="center">
	<!-- datagrid信息表 -->
	<table id="datagrid_table"></table>
	<!-- 添加记录 -->
	<div id="datagrid_add">
		<form id="add_form" action="questionInfo/insertQuestion.do" method="post">			
			<table width="630" class="xxl_tb_1">
				<tbody>	
					<!-- <tr>
						<td width="120" class="xxl_td_2">问题标题：</td>
						<td width="360px"><input type="text" id="questionContent" name="questionContent" style="width:360px;" /></td>
						<td width="100"><div id="questionContentTip" style="width: 100px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">问题内容：</td>
						<td><input type="text" id="questionDesc" name="questionDesc" style="width:360px;"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">问题类型：</td>
						<td><input type="text" id="typeId" name="typeId"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">评论数：</td>
						<td><input type="text" id="commentNum" name="commentNum"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">点赞数：</td>
						<td><input type="text" id="goodNum" name="goodNum"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">问题查看数：</td>
						<td><input type="text" id="questionViewNum" name="questionViewNum"/></td>
					</tr>
					<tr>
						<td colspan="3" style="text-align: center">					
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="addFormSubmit()">添加</a>
							<a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('add_form').reset()">重置</a>
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_add').window('close');">取消</a>
						</td>
					</tr> -->
				</tbody>
			</table>
		</form>
	</div>
	
	<!-- 修改记录 -->
	<div id="datagrid_update">
		<form id="update_form" action="questionComment/updateById.do" method="post">
			<input type="hidden" id="idUpdate" name="id"/>
			<input type="hidden" id="questionIdUpdate" name="questionId"/>
			<input type="hidden" id="userIdUpdate" name="userId"/>
			<table width="630" class="xxl_tb_1">
				<tbody>
					<tr>
						<td width="120" class="xxl_td_2">回答内容：</td>
						<td ><input type="text"  id="commentContentUpdate" name="commentContent" style="width:360px;"/></td>
					</tr>
					<!-- <tr>
						<td class="xxl_td_2">问题内容：</td>
						<td><input type="text" id="questionDescUpdate" name="questionDesc" style="width:360px;"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">问题类型：</td>
						<td><input type="text" id="typeIdUpdate" name="typeId"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">评论数：</td>
						<td><input type="text" id="commentNumUpdate" name="commentNum"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">点赞数：</td>
						<td><input type="text" id="goodNumUpdate" name="goodNum"/></td>
					</tr> -->
					
					<tr>
						<td colspan="3" style="text-align: center">
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="updateFormSubmit()">修改</a>		
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_update').window('close');">取消</a>
						</td>
					</tr> 
				</tbody>
			</table>
		</form>
	</div>
	</div>

</body>
</html>